﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Dynamic;
using Eisk.BusinessEntities;

namespace Eisk.BusinessLogicLayer
{
    public partial class SupplierBLL
    {
        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
        public List<Supplier> GetSupplierByReportsToPaged(string orderBy = default(string), int startRowIndex = default(int), int maximumRows = default(int))
        {
            if (string.IsNullOrEmpty(orderBy))
                orderBy = "SupplierId";

            if (startRowIndex < 0)
                throw (new ArgumentOutOfRangeException("startRowIndex"));

            if (maximumRows < 0)
                throw (new ArgumentOutOfRangeException("maximumRows"));

            return (
                    from employee in
                        _DatabaseContext.Suppliers
                         .DynamicOrderBy(orderBy)
                    select employee
                    )
                    .Skip(startRowIndex)
                    .Take(maximumRows)
                    .ToList();


        }

        [System.ComponentModel.DataObjectMethodAttribute(System.ComponentModel.DataObjectMethodType.Select, false)]
        public List<Supplier> GetAllSupplierPaged(string orderBy = default(string), int startRowIndex = default(int), int maximumRows = default(int))
        {
            if (string.IsNullOrEmpty(orderBy))
                orderBy = "SupplierId";

            if (startRowIndex < 0)
                throw (new ArgumentOutOfRangeException("startRowIndex"));

            if (maximumRows < 0)
                throw (new ArgumentOutOfRangeException("maximumRows"));

            return (
                    from employee in
                        _DatabaseContext.Suppliers.DynamicOrderBy(orderBy)
                    select employee
                    )
                    .Skip(startRowIndex)
                    .Take(maximumRows)
                    .ToList();
        }
        public int GetTotalCountForAllSupplierByReportsTo(string orderBy = default(string), int startRowIndex = default(int), int maximumRows = default(int))
        {
            return _DatabaseContext.Suppliers.Count();
        }

    }
}